using GrapeCity.Forguncy.CellTypes;
using GrapeCity.Forguncy.Plugin;
using System;
using System.ComponentModel;
using System.Windows;

namespace MarkedRenderer
{
    [Icon("pack://application:,,,/MarkedRenderer;component/Resources/Icon.png")]
    [Designer(typeof(MarkedRendererCellTypeDesigner))]
    public class MarkedRendererCellType : CellType, ISupportDefaultValue
    {

        //public Object DefaultMarkdownContent { get; set; }

        [SupportModifyByRuntimeProperty]
        [FormulaProperty(AcceptsReturn = true, CanSelectResource = false)]
        [DisplayName("默认 Markdown 文本")]
        [Description("支持基于标准 Markdown 语法的文本; \n支持多行文本输入，设计器内 shift + enter 换行即可，无需输入换行符\\n")]
        public object DefaultValue { get; set; }

        [DisplayName("开启数学公式支持")]
        [Description("数学公式基于 Katex，会加载额外资源，按需开启")]
        public bool SupportKatex { get; set; } = false;

        public bool NeedFormatDefaultValue => false;

        public override string ToString()
        {
            return "Markdown 渲染器";
        }
    }

    public class MarkedRendererCellTypeDesigner : CellTypeDesigner<MarkedRendererCellType>
    {
        public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
        {
            return drawingHelper.GetHeadlessBrowserPreviewControl(); // 使用无头浏览器渲染设计时预览
        }
    }
}
